<template>
	<view class="mine">
		<view class="mine-head">
			<view class="mine-head__user">
				<image class="mine-head__avatar" :src="avatarBase64Img" />
				<view class="mine-head__info">
					<text class="mine-head__name">{{meInfo.UserName}}</text>
					<text class="mine-head__phone">账号：{{meInfo.Telephone}}</text>
				</view>
				<view class="mine-head__edit" @click="toUserConfig">
					<image src="../../static/img/icon-edit-rect.png" />
				</view>
			</view>
			<view class="mine-head__workcard">
				上岗证：{{meInfo.IdCard}}
			</view>
			<view class="mine-head__service">
				<text>服务网点：{{meInfo.ServiceSite}}</text>
				<text>服务区域：{{meInfo.ServiceZone}}</text>
			</view>
		</view>
		<view class="mine-cell-list">
			<button class="mine-cell">
				<view class="mine-cell__icon">
					<image mode="aspectFit" src="../../static/img/icon-idcard.png" />
				</view>
				<view class="mine-cell__value">
					<text>电子工牌</text>
					<image src="../../static/img/icon-arrowright-black.png" />
				</view>
			</button>
			<button class="mine-cell" @click="toChangPwd">
				<view class="mine-cell__icon">
					<image mode="aspectFit" src="../../static/img/icon-lock.png" />
				</view>
				<view class="mine-cell__value">
					<text>修改密码</text>
					<image src="../../static/img/icon-arrowright-black.png" />
				</view>
			</button>
			<button class="mine-cell" @click="ShowAngelServiceShare">
				<view class="mine-cell__icon">
					<image mode="aspectFit" src="../../static/img/icon-share.png" />
				</view>
				<view class="mine-cell__value" >
					<text>分享安吉尔服务</text>
					<image src="../../static/img/icon-arrowright-black.png" />
				</view>
			</button>
			<button class="mine-cell">
				<view class="mine-cell__icon">
					<image mode="aspectFit" src="../../static/img/icon-about.png" />
				</view>
				<view class="mine-cell__value">
					<text>关于</text>
					<image src="../../static/img/icon-arrowright-black.png" />
				</view>
			</button>
			<button class="mine-cell">
				<view class="mine-cell__icon">
					<image mode="aspectFit" src="../../static/img/icon-setting.png" />
				</view>
				<view class="mine-cell__value noborder">
					<text>设置</text>
					<image src="../../static/img/icon-arrowright-black.png" />
				</view>
			</button>
		</view>
		<view class="mine-footer">
			<button class="cu-btn block primary lg" @click="logoutBtn">退出登录</button>
		</view>
		<SharePopup ref="SharePopup" :engineerShareImg="engineerShareImg"></SharePopup>
	</view>
	
</template>
<script>
    import SharePopup from '../../components/SharePopup'
	export default {
		components:{
			 SharePopup,
		},
		data() {
			return {
				meInfo: {},
				avatarBase64Img: "",
				engineerShareImg: ""
			}
		},
		watch: {
			meInfo(val) {
				if (val.EngineerShareImgType == ".png") {
					this.engineerShareImg = `data:image/png;base64,${val.EngineerShareImg}`
				} else {
					this.engineerShareImg = `data:image/jpg;base64,${val.EngineerShareImg}`
				}
				
				if(val.Image){
					this.avatarBase64Img = `data:image/png;base64,${val.Image}`
				}
			}
		},
		mounted() {
			uni.showLoading({
				title:"加载中...",
				mask:true
			})
			this.getMeInfo();
		},
		onLoad(e) {
			uni.showLoading({
				title:"加载中...",
				mask:true
			})
			this.getMeInfo();
			
		},
		onShow(e){
		
		},
		methods: {
			async getMeInfo() {
				let uPhone = this.UserInfo.mobile;
				let token = this.UserInfo.RetId;
				let {
					RetBool,
					RetObject
				} = await this.meService.getUserInfoAsync(uPhone, token);
				if (RetBool && RetObject) {
					this.meInfo = JSON.parse(RetObject);
					console.log(this.meInfo)
				}
                uni.hideLoading();
			},
			toChangPwd(e) {
				uni.navigateTo({
					url: "../modifypwd/index"
				})
			},
			toUserConfig(e) {
	
				uni.navigateTo({
					url: "../userconfig/index",
					complete: () => {
						
					}
				})
			},
			logoutBtn(e) {
				this.UserInfo = null;
				uni.reLaunch({
				    url: '../login/index'
				});
			},
			ShowAngelServiceShare(e){
				//console.log(this.$refs.SharePopup);
				this.$refs.SharePopup.openPoPup();
			}
		}
	}
</script>
<style lang="scss">
	@import './index.scss';
</style>
